package com.lycafly.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lycafly.R;

public class TestFragment extends Fragment {
	private static final String KEY_CONTENT = "TestFragment:Content";

	public static TestFragment newInstance(String content, int mImage) {
		TestFragment fragment = new TestFragment();

		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < 20; i++) {
			builder.append(content).append(" ");
		}
		builder.deleteCharAt(builder.length() - 1);
		fragment.mContent = builder.toString();
		fragment.mImage = mImage;
		return fragment;
	}

	private String mContent = "???";
	private int mImage;

	ViewHolder viewHolder = null;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		// TextView text = new TextView(getActivity());
		// text.setGravity(Gravity.CENTER);
		// text.setText(mContent);
		// text.setTextSize(20 * getResources().getDisplayMetrics().density);
		// text.setPadding(20, 20, 20, 20);
		//
		// LinearLayout layout = new LinearLayout(getActivity());
		// layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
		// LayoutParams.FILL_PARENT));
		// layout.setGravity(Gravity.CENTER);
		// layout.addView(text);

		viewHolder = new ViewHolder();

		View view = inflater.inflate(R.layout.fragment_home, container, false);

		viewHolder.tv = (TextView) view.findViewById(R.id.textView);

		viewHolder.iv = (ImageView) view.findViewById(R.id.imageView);

		viewHolder.tv.setText(mContent);

		viewHolder.iv.setImageResource(mImage);

		return view;
	}

	static class ViewHolder {
		TextView tv;

		ImageView iv;

	}

}
